import { Loading } from "element-ui";

let loadingNum = 0;
/** 全局loadding */
export const useGlobelLoading = func => {
    return async function(...args) {
        const loading = Loading.service({
            customClass: "sc-loading",
            lock: true,
            text: "Loading",
            spinner: "el-icon-loading",
            background: "rgba(0, 0, 0, 0.7)"
        });
        loadingNum++;
        await func.apply(this, args);
        loadingNum--;
        if (loadingNum < 1) {
            loading.close();
        }
    };
};
